/********************************************************
 Name          : AntelCfgOID.h
 Author        : Khachatur Gyozalyan
 Copyright     : Copyright by Antel Systems
 Description   :
 **********************************************************/
// Include Files
#ifndef ANTELCFGOID_H_
#define ANTELCFGOID_H_

#define USER_DEF_CONFIG_FILE    0
#define FACTORY_CONFIG_FILE     1
#define CALIBRATION_TABLE_FILE  2

//-----------------------USER DEFINED CONFIGURATION PARAMETERS SIZE--------------------------------------------

#define SIZEOF_FREQUENCY_CARRIER_NUMBER 	4
#define SIZEOF_OUTPUT_POWER             	1
#define SIZEOF_SYMBOL_RATE		           	1
#define SIZEOF_CANNEL                   	(SIZEOF_FREQUENCY_CARRIER_NUMBER + SIZEOF_OUTPUT_POWER + SIZEOF_SYMBOL_RATE)

#define SIZEOF_CANNEL_TABLE             	(32 * SIZEOF_CANNEL)

#define SIZEOF_USER_NAME                	16
#define SIZEOF_UNIT_NAME                	16
#define SIZEOF_LOCATION                 	16
#define SIZEOF_DEVICE_INDIVIDUALIZATION      	(SIZEOF_USER_NAME + SIZEOF_UNIT_NAME + SIZEOF_LOCATION)

#define SIZEOF_PRIMARY_INTERFACE_SELECT		1
#define SIZEOF_INTERFACE_TIMEOUT				1
#define SIZEOF_ASYNCHRONOUS_BAUDRATE    	4
#define SIZEOF_ASYNCHRONOUS_DATABITS    	1
#define SIZEOF_ASYNCHRONOUS_PARITY	    	1
#define SIZEOF_ASYNCHRONOUS_STOPBITS    	1
#define SIZEOF_ASYNCHRONOUS_FLOWCONTROL 	1

#define SIZEOF_ASYNCHRONOUS	            	(SIZEOF_PRIMARY_INTERFACE_SELECT + SIZEOF_INTERFACE_TIMEOUT + SIZEOF_ASYNCHRONOUS_BAUDRATE + SIZEOF_ASYNCHRONOUS_DATABITS + SIZEOF_ASYNCHRONOUS_PARITY + SIZEOF_ASYNCHRONOUS_STOPBITS + SIZEOF_ASYNCHRONOUS_FLOWCONTROL)

#define SIZEOF_SLEEP_MODE_REG           	1
#define SIZEOF_QUIET_TIMEOUT            	1
#define SIZEOF_WAKEUP_TIMEOUT           	1

#define SIZEOF_SLEEP_MODE                	(SIZEOF_SLEEP_MODE_REG + SIZEOF_QUIET_TIMEOUT + SIZEOF_WAKEUP_TIMEOUT)

#define SIZEOF_OPERATION_SETTINGS       	(SIZEOF_DEVICE_INDIVIDUALIZATION + SIZEOF_ASYNCHRONOUS + SIZEOF_SLEEP_MODE)

#define SIZEOF_CANNEL_NUMBER            	1
#define SIZEOF_OUTPUT_POWER_LEVEL       	1
#define SIZEOF_MODULATION_TYPE          	1
#define SIZEOF_FEC_TYPE						1
#define SIZEOF_SCRAM						1
#define SIZEOF_CARRIER_FREQ_NUMBER			2
#define SIZEOF_FREQ_NUMBER_SYMBOLRATE		SIZEOF_SYMBOL_RATE
#define SIZEOF_UHF							(SIZEOF_CANNEL_NUMBER + SIZEOF_OUTPUT_POWER_LEVEL + SIZEOF_MODULATION_TYPE + SIZEOF_FEC_TYPE + SIZEOF_SCRAM + SIZEOF_CARRIER_FREQ_NUMBER + SIZEOF_FREQ_NUMBER_SYMBOLRATE)

#define SIZEOF_BRIDGING_PROTOCOL			1
#define SIZEOF_SNMP_PROTOCOL				1
#define SIZEOF_SNMP_TRAP_TIMEOUT			2
#define SIZEOF_NETWORK_PROTOCOL_SETTINGS	(SIZEOF_BRIDGING_PROTOCOL + SIZEOF_SNMP_PROTOCOL + SIZEOF_SNMP_TRAP_TIMEOUT)

#define SIZEOF_NETWORK_REGISTER				1
#define SIZEOF_ACCESS_POINT_NAME			32
#define SIZEOF_SSID							32
#define SIZEOF_WIFI_SETTINGS				(SIZEOF_NETWORK_REGISTER + SIZEOF_ACCESS_POINT_NAME + SIZEOF_SSID)

#define SIZEOF_TCPIP_REGISTER				1
#define SIZEOF_IP_ADDRESS					(1+1+1+1)
#define SIZEOF_SUBNET_MASK					(1+1+1+1)
#define SIZEOF_DEFAULT_GATEWAY				(1+1+1+1)
#define SIZEOF_DNS_SERVER					(1+1+1+1)
#define SIZEOF_TCPIP_SETTINGS				(SIZEOF_TCPIP_REGISTER + SIZEOF_IP_ADDRESS + SIZEOF_SUBNET_MASK + SIZEOF_DEFAULT_GATEWAY + SIZEOF_DNS_SERVER)

#define SIZEOF_SECURITY_TYPE				1
#define SIZEOF_ENCRYPTION_TYPE				1
#define SIZEOF_SECURITY_KEY					16
#define SIZEOF_NETWORK_SECURITY				(SIZEOF_SECURITY_TYPE + SIZEOF_ENCRYPTION_TYPE + SIZEOF_SECURITY_KEY)

#define SIZEOF_NETWORK_SETTINGS				(SIZEOF_NETWORK_PROTOCOL_SETTINGS + SIZEOF_WIFI_SETTINGS + SIZEOF_TCPIP_SETTINGS + SIZEOF_NETWORK_SECURITY)

//--------------------------------FACTORY CONFIGURATION PARAMETERS SIZE-------------------------------------------------

#define SIZEOF_MODEL						16
#define SIZEOF_DESCRIPTION					80
#define SIZEOF_PCBA_VERSION					16
#define SIZEOF_SOFTWARE_VERSION				16
#define SIZEOF_GMSK_IMAGE_VERSION			16
#define SIZEOF_FSK_IMAGE_VERSION			16
#define SIZEOF_QAM_IMAGE_VERSION			16
#define SIZEOF_ZIGBEE_IMAGE_VERSION			16
#define SIZEOF_IDENT_RESERVED				20

#define SIZEOF_SOFTWARE_IDENTIFICATION    (SIZEOF_MODEL + SIZEOF_DESCRIPTION + SIZEOF_PCBA_VERSION + SIZEOF_SOFTWARE_VERSION + SIZEOF_GMSK_IMAGE_VERSION + SIZEOF_FSK_IMAGE_VERSION + SIZEOF_QAM_IMAGE_VERSION + SIZEOF_ZIGBEE_IMAGE_VERSION + SIZEOF_IDENT_RESERVED)

#define SIZEOF_SERIAL_NUMBER_MAC			12
#define SIZEOF_MANUFACTORING_SERIAL_NUMBER	16
#define SIZEOF_SECRET_KEY					16
//#define SIZEOF_BOOT_VERSION					12

#define SIZEOF_SYSTEM_IDENTIFICATION    (SIZEOF_SERIAL_NUMBER_MAC + SIZEOF_MANUFACTORING_SERIAL_NUMBER + SIZEOF_SECRET_KEY)

#define SIZEOF_IDENTIFICATION    (SIZEOF_SOFTWARE_IDENTIFICATION + SIZEOF_SYSTEM_IDENTIFICATION)

//--------------------------------CALIBRATION TABLE PARAMETERS SIZE---------------------------------
#define SIZEOF_MAX_OUTPUT_POWER						1
#define SIZEOF_MIN_OUTPUT_POWER						1
#define SIZEOF_NUMBER_OF_FREQUENCY_SUB_BANDS		1
#define SIZEOF_NUMBER_OF_OUTPUT_POWER_LEVELS		1
#define SIZEOF_STOP_FREQBAND						4
#define SIZEOF_FREQERR								2
//#define SIZEOF_FREQ                                4
//#define SIZEOF_IQ_ATTENUATOR                       2

#define SIZEOF_FUNCTIONAL    (SIZEOF_MAX_OUTPUT_POWER + SIZEOF_MIN_OUTPUT_POWER + SIZEOF_NUMBER_OF_FREQUENCY_SUB_BANDS + SIZEOF_NUMBER_OF_OUTPUT_POWER_LEVELS + SIZEOF_STOP_FREQBAND + SIZEOF_FREQERR /*+ SIZEOF_FREQ + SIZEOF_IQ_ATTENUATOR*/)

#define SIZEOF_GENERAL_PURPOSE_CALIBRATION         (SIZEOF_FUNCTIONAL)

#define MAX_FREQ_SUB_BAND_N         16
#define MAX_OUTPUT_POWER_LEVELS_M   16

#define SIZEOF_OUTPUT_POWER_V			1
#define SIZEOF_FWD_ATTENUATOR			1
#define SIZEOF_FEEDBACK_ATTENUATOR		1
//#define SIZEOF_TSSI					2
#define SIZEOF_PHASE_SHIFT				1
#define SIZEOF_VAPC						2
#define SIZEOF_BASEBAND_ATTENUATOR		2

#define SIZEOF_OUTPUT_POWER_LEVEL_M    (SIZEOF_OUTPUT_POWER_V + SIZEOF_FWD_ATTENUATOR + SIZEOF_FEEDBACK_ATTENUATOR /*+ SIZEOF_TSSI*/ + SIZEOF_PHASE_SHIFT + SIZEOF_VAPC + SIZEOF_BASEBAND_ATTENUATOR)


#define SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS               ((SIZEOF_OUTPUT_POWER_LEVEL_M * MAX_OUTPUT_POWER_LEVELS_M))


/*#define SIZEOF_K_COEFFICIENT_OF_RSSI            2
#define SIZEOF_B_COEFFICIENT_OF_RSSI            2
#define SIZEOF_HIGH_GAIN_SWITCHING_RSSI_LEVEL   2
#define SIZEOF_LOW_GAIN_SWITCHING_RSSI_LEVEL    2
#define SIZEOF_I_DC_OFFSET_FOR_HIGH_GAIN        2
#define SIZEOF_Q_DC_OFFSET_FOR_HIGH_GAIN        2
#define SIZEOF_I_DC_OFFSET_FOR_LOW_GAIN         2
#define SIZEOF_Q_DC_OFFSET_FOR_LOW_GAIN         2*/
#define SIZEOF_SUB_BAND_START_FREQ				4
#define SIZEOF_RECEIVER_SYSTEM_GAIN				4
#define SIZEOF_AGC_TABLE						2*16
#define SIZEOF_CHANNEL_EQUALIZATION_TABLE		2*126
#define SIZEOF_BASEBAND_AMPLIFIER_TABLE			4*32

//#define SIZEOF_RSSI   (SIZEOF_K_COEFFICIENT_OF_RSSI + SIZEOF_B_COEFFICIENT_OF_RSSI + SIZEOF_HIGH_GAIN_SWITCHING_RSSI_LEVEL + SIZEOF_LOW_GAIN_SWITCHING_RSSI_LEVEL + SIZEOF_I_DC_OFFSET_FOR_HIGH_GAIN + SIZEOF_Q_DC_OFFSET_FOR_HIGH_GAIN + SIZEOF_I_DC_OFFSET_FOR_LOW_GAIN + SIZEOF_Q_DC_OFFSET_FOR_LOW_GAIN)
#define SIZEOF_RSSI   (SIZEOF_SUB_BAND_START_FREQ + SIZEOF_RECEIVER_SYSTEM_GAIN + SIZEOF_AGC_TABLE + SIZEOF_CHANNEL_EQUALIZATION_TABLE + SIZEOF_BASEBAND_AMPLIFIER_TABLE)

//#define SIZEOF_RECEIVER_CALIBRATION_PARAMETERS        (SIZEOF_RSSI)
//------------------------------------------------------------------------------------------------------------

struct Object
{
	int * size;
	int Object_size;
};

struct Node
{
	struct Object * Objects;
	int Node_size;
};

struct CfgFile
{
	struct Node * Nodes;
	unsigned int sector_number;
};

extern unsigned char gBoot_option;

void cfg_init(void);
struct CfgFile * get_cfg_file(int file_index);
int get_cfg_address(struct CfgFile * Cfg,int id_0,int id_1,int id_2);
int get_cfg_size(struct CfgFile * Cfg,int id_0,int id_1,int id_2);
void get_cfg(struct CfgFile * Cfg,void * data,int id_0,int id_1,int id_2);
void get_cbtb(struct CfgFile * Cfg, void * data, int size, int address);
int get_object_address(struct CfgFile * Cfg,int id_0,int id_1);
int get_object_size(struct CfgFile * Cfg,int id_0,int id_1);
void get_object(struct CfgFile * Cfg,void * data,int id_0,int id_1);
int get_node_address(struct CfgFile * Cfg,int id_0);
int get_node_size(struct CfgFile * Cfg,int id_0);
void get_node(struct CfgFile * Cfg,void * data,int id_0);

void get_user_cfg_object(void * data,int id_0,int id_1);
void get_user_cfg_cfg(void * data,int id_0,int id_1,int id_2);


#define USER_OID_CHANNEL(ptr_cfg,num)                      get_user_cfg_object(ptr_cfg,1,num) // 1.num.x
#define USER_OID_FREQUENCY_CARRIER_NUMBER(ptr_cfg,num)     get_user_cfg_cfg(ptr_cfg,1,num,1)  // 1.num.1
#define USER_OID_OUTPUT_POWER(ptr_cfg,num)                 get_user_cfg_cfg(ptr_cfg,1,num,2)  // 1.num.2
#define USER_OID_SYMBOL_RATE(ptr_cfg,num)				   get_user_cfg_cfg(ptr_cfg,1,num,3)  // 1.num.3

#define USER_OID_DEVICE_INDIVIDUALIZATION(ptr_cfg)         get_user_cfg_object(ptr_cfg,2,1)   // 2.1.x
#define USER_OID_USER_NAME(ptr_cfg)                        get_user_cfg_cfg(ptr_cfg,2,1,1)    // 2.1.1
#define USER_OID_UNIT_NAME(ptr_cfg)                        get_user_cfg_cfg(ptr_cfg,2,1,2)    // 2.1.2
#define USER_OID_LOCATION(ptr_cfg)                         get_user_cfg_cfg(ptr_cfg,2,1,3)    // 2.1.3

#define USER_OID_ASYNCHRONOUS(ptr_cfg)                     get_user_cfg_object(ptr_cfg,2,2)   // 2.2.x
#define USER_OID_PRIMARY_INTERFACE_SELECT(ptr_cfg)         get_user_cfg_cfg(ptr_cfg,2,2,1)    // 2.2.1
#define USER_OID_INTERFACE_TIMEOUT(ptr_cfg) 	               get_user_cfg_cfg(ptr_cfg,2,2,2)    // 2.2.2
#define USER_OID_ASYNCHRONOUS_BAUDRATE(ptr_cfg)            get_user_cfg_cfg(ptr_cfg,2,2,3)    // 2.2.3
#define USER_OID_ASYNCHRONOUS_DATABITS(ptr_cfg)            get_user_cfg_cfg(ptr_cfg,2,2,4)    // 2.2.4
#define USER_OID_ASYNCHRONOUS_PARITY(ptr_cfg)              get_user_cfg_cfg(ptr_cfg,2,2,5)    // 2.2.5
#define USER_OID_ASYNCHRONOUS_STOPBITS(ptr_cfg)            get_user_cfg_cfg(ptr_cfg,2,2,6)    // 2.2.6
#define USER_OID_ASYNCHRONOUS_FLOWCONTROL(ptr_cfg)         get_user_cfg_cfg(ptr_cfg,2,2,7)    // 2.2.7

#define USER_OID_SLEEP_MODE(ptr_cfg)                       get_user_cfg_object(ptr_cfg,2,3)   // 2.3.x
#define USER_OID_SLEEP_MODE_REG(ptr_cfg)                   get_user_cfg_cfg(ptr_cfg,2,3,1)    // 2.3.1
#define USER_OID_QUIET_TIMEOUT(ptr_cfg)                    get_user_cfg_cfg(ptr_cfg,2,3,2)    // 2.3.2
#define USER_OID_WAKEUP_TIMEOUT(ptr_cfg)                   get_user_cfg_cfg(ptr_cfg,2,3,3)    // 2.3.3

#define USER_OID_UHF_SETTINGS(ptr_cfg)                     get_user_cfg_object(ptr_cfg,3,1)   // 3.1.x
#define USER_OID_CHANNEL_NUMBER(ptr_cfg)                   get_user_cfg_cfg(ptr_cfg,3,1,1)    // 3.1.1
#define USER_OID_OUTPUT_POWER_WL(ptr_cfg)                  get_user_cfg_cfg(ptr_cfg,3,1,2)    // 3.1.2
#define USER_OID_MODULATION_TYPE(ptr_cfg)                  get_user_cfg_cfg(ptr_cfg,3,1,3)    // 3.1.3
#define USER_OID_FEC_TYPE(ptr_cfg)   		               get_user_cfg_cfg(ptr_cfg,3,1,4)    // 3.1.4
#define USER_OID_SCRAM(ptr_cfg) 	  		               get_user_cfg_cfg(ptr_cfg,3,1,5)    // 3.1.5
#define USER_OID_CARRIER_FREQ_NUMBER(ptr_cfg)              get_user_cfg_cfg(ptr_cfg,3,1,6)    // 3.1.6
#define USER_OID_FREQ_NUMBER_SYMBOLRATE(ptr_cfg)           get_user_cfg_cfg(ptr_cfg,3,1,7)    // 3.1.7

#define USER_OID_NETWORK_PROTOCOL_SETTINGS(ptr_cfg)        get_user_cfg_object(ptr_cfg,4,1)   // 4.1.x
#define USER_OID_BRIDGING_PROTOCOL(ptr_cfg)                get_user_cfg_cfg(ptr_cfg,4,1,1)    // 4.1.1
#define USER_OID_SNMP_PROTOCOL(ptr_cfg)					   get_user_cfg_cfg(ptr_cfg,4,1,2)    // 4.1.2
#define USER_OID_SNMP_TRAP_TIMEOUT(ptr_cfg)                get_user_cfg_cfg(ptr_cfg,4,1,3)    // 4.1.3

#define USER_OID_WIFI_SETTINGS(ptr_cfg)				       get_user_cfg_object(ptr_cfg,4,2)   // 4.2.x
#define USER_OID_NETWORK_REGISTER(ptr_cfg)	               get_user_cfg_cfg(ptr_cfg,4,2,1)    // 4.2.1
#define USER_OID_ACCESS_POINT_NAME(ptr_cfg)				   get_user_cfg_cfg(ptr_cfg,4,2,2)    // 4.2.2
#define USER_OID_SSID(ptr_cfg)				               get_user_cfg_cfg(ptr_cfg,4,2,3)    // 4.2.3

#define USER_OID_TCPIP_SETTINGS(ptr_cfg)			       get_user_cfg_object(ptr_cfg,4,3)   // 4.3.x
#define USER_OID_TCPIP_REGISTER(ptr_cfg)	               get_user_cfg_cfg(ptr_cfg,4,3,1)    // 4.3.1
#define USER_OID_IP_ADDRESS(ptr_cfg)					   get_user_cfg_cfg(ptr_cfg,4,3,2)    // 4.3.2
#define USER_OID_SUBNET_MASK(ptr_cfg)		               get_user_cfg_cfg(ptr_cfg,4,3,3)    // 4.3.3
#define USER_OID_DEFAULT_GATEWAY(ptr_cfg)				   get_user_cfg_cfg(ptr_cfg,4,3,4)    // 4.3.4
#define USER_OID_DNS_SERVER(ptr_cfg)		               get_user_cfg_cfg(ptr_cfg,4,3,5)    // 4.3.5

#define USER_OID_NETWORK_SECURITY(ptr_cfg)			       get_user_cfg_object(ptr_cfg,4,4)   // 4.4.x
#define USER_OID_SECURITY_TYPE(ptr_cfg)		               get_user_cfg_cfg(ptr_cfg,4,4,1)    // 4.4.1
#define USER_OID_ENCRYPTION_TYPE(ptr_cfg)				   get_user_cfg_cfg(ptr_cfg,4,4,2)    // 4.4.2
#define USER_OID_SECURITY_KEY(ptr_cfg)		               get_user_cfg_cfg(ptr_cfg,4,4,3)    // 4.4.3

//-------------------------------FACTORY PARAMETERS FUNCTIONS----------------------------------------------
#define FCFG_OID_SOFTWARE_IDENTIFICATION(ptr_cfg)          get_object(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1)    // 1.1.x
#define FCFG_OID_MODEL(ptr_cfg)                            get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,1)     // 1.1.1
#define FCFG_OID_DESCRIPTION(ptr_cfg)                      get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,2)     // 1.1.2
#define FCFG_OID_PCBA_VERSION(ptr_cfg)                     get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,3)     // 1.1.3
#define FCFG_OID_SOFTWARE_VERSION(ptr_cfg)                 get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,4)     // 1.1.4
#define FCFG_OID_GMSK_IMAGE_VERSION(ptr_cfg)               get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,5)     // 1.1.5
#define FCFG_OID_FSK_IMAGE_VERSION(ptr_cfg)                get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,6)     // 1.1.6
#define FCFG_OID_QAM_IMAGE_VERSION(ptr_cfg)                get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,7)     // 1.1.7
#define FCFG_OID_ZIGBEE_IMAGE_VERSION(ptr_cfg)             get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,8)     // 1.1.8
//32 bytes reserved 1.9
#define FCFG_OID_SYSTEM_IDENTIFICATION(ptr_cfg)		       get_object(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,2)    // 1.2.x
#define FCFG_OID_SERIAL_NUMBER_MAC(ptr_cfg)                get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,2,1)     // 1.2.1
#define FCFG_OID_MANUFACTORING_SERIAL_NUMBER(ptr_cfg)      get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,2,2)     // 1.2.2
#define FCFG_OID_SECRET_KEY(ptr_cfg)		               get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,2,3)     // 1.2.3
//#define FCFG_OID_BOOT_VERSION(ptr_cfg)                     get_cfg(get_cfg_file(FACTORY_CONFIG_FILE),ptr_cfg,1,1,5)     // 1.1.5

//-------------------------------CALIBRATION PARAMETERS FUNCTIONS----------------------------------------------
#define get_cbtb_object get_cbtb
#define CBTB_OID_FUNCTIONAL(ptr_cfg)						get_cbtb_object(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_FUNCTIONAL, 0)    // 1.1.x
#define CBTB_OID_MAX_OUTPUT_POWER(ptr_cfg)					get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_MAX_OUTPUT_POWER, 0)// 1.1.1
#define CBTB_OID_MIN_OUTPUT_POWER(ptr_cfg)					get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_MIN_OUTPUT_POWER, \
																	SIZEOF_MAX_OUTPUT_POWER) // 1.1.2
#define CBTB_OID_NUMBER_OF_FREQUENCY_SUB_BANDS(ptr_cfg)		get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_NUMBER_OF_FREQUENCY_SUB_BANDS, \
																	SIZEOF_MAX_OUTPUT_POWER + SIZEOF_MIN_OUTPUT_POWER) // 1.1.3
#define CBTB_OID_NUMBER_OF_OUTPUT_POWER_LEVELS(ptr_cfg)		get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_NUMBER_OF_OUTPUT_POWER_LEVELS, \
																	SIZEOF_MAX_OUTPUT_POWER + SIZEOF_MIN_OUTPUT_POWER + SIZEOF_NUMBER_OF_FREQUENCY_SUB_BANDS) // 1.1.4
#define CBTB_OID_STOP_FREQBAND(ptr_cfg)						get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_STOP_FREQBAND, \
																	SIZEOF_MAX_OUTPUT_POWER + SIZEOF_MIN_OUTPUT_POWER + SIZEOF_NUMBER_OF_FREQUENCY_SUB_BANDS \
																	+ SIZEOF_NUMBER_OF_OUTPUT_POWER_LEVELS) // 1.1.5
#define CBTB_OID_FREQERR(ptr_cfg)							get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_FREQERR, \
																	SIZEOF_MAX_OUTPUT_POWER + SIZEOF_MIN_OUTPUT_POWER + SIZEOF_NUMBER_OF_FREQUENCY_SUB_BANDS \
																	+ SIZEOF_NUMBER_OF_OUTPUT_POWER_LEVELS + SIZEOF_STOP_FREQBAND) // 1.1.6
//#define CBTB_OID_FREQ(ptr_cfg)							get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,1,1,6)// 1.1.6
//#define CBTB_OID_IQ_ATTENUATOR(ptr_cfg)					get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,1,1,7)// 1.1.7

#define CBTB_OID_TRANSMITER_OPL(ptr_cfg,N,M)				get_cbtb_object(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_OUTPUT_POWER_LEVEL_M, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (M - 1) + 0) 
#define CBTB_OUD_OUTPUT_POWER(ptr_cfg,N,M)					get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_OUTPUT_POWER, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (M - 1) + 0) // 2*(N-1)+2.M.1
#define CBTB_OUD_FWD_ATTENUATOR(ptr_cfg,N,M)				get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_FWD_ATTENUATOR, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (M - 1) + \
																SIZEOF_OUTPUT_POWER) // 2*(N-1)+2.M.2
#define CBTB_OUD_FEEDBACK_ATTENUATOR(ptr_cfg,N,M)			get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_FEEDBACK_ATTENUATOR, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (M - 1) + \
																SIZEOF_OUTPUT_POWER + SIZEOF_FWD_ATTENUATOR) // 2*(N-1)+2.M.3
//#define CBTB_OUD_TSSI(ptr_cfg,N,M)						get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+2,M,4)     // 2*(N-1)+2.M.4
#define CBTB_OUD_PHASE_SHIFT(ptr_cfg,N,M)					get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_PHASE_SHIFT, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (M - 1) + \
																SIZEOF_OUTPUT_POWER + SIZEOF_FWD_ATTENUATOR + SIZEOF_FEEDBACK_ATTENUATOR) // 2*(N-1)+2.M.4
#define CBTB_OUD_VAPC(ptr_cfg,N,M)							get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_VAPC, \
																 SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (M - 1) + \
																SIZEOF_OUTPUT_POWER + SIZEOF_FWD_ATTENUATOR + SIZEOF_FEEDBACK_ATTENUATOR + \
																SIZEOF_PHASE_SHIFT) // 2*(N-1)+2.M.5
#define CBTB_OUD_BASEBAND_ATTENUATOR(ptr_cfg,N,M)			get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_BASEBAND_ATTENUATOR, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (M - 1) + \
																SIZEOF_OUTPUT_POWER + SIZEOF_FWD_ATTENUATOR + SIZEOF_FEEDBACK_ATTENUATOR + \
																SIZEOF_PHASE_SHIFT + SIZEOF_VAPC) // 2*(N-1)+2.M.6

#define CBTB_OID_RECEIVER_RSSI(ptr_cfg,N)					get_cbtb_object(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_RSSI, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (17 - 1) + 0)
#define CBTB_OUD_SUB_BAND_START_FREQ(ptr_cfg,N)				get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_SUB_BAND_START_FREQ, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (17 - 1) + 0) // 2*(N-1)+2.1.1
#define CBTB_OUD_RECEIVER_SYSTEM_GAIN(ptr_cfg,N)			get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_RECEIVER_SYSTEM_GAIN, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (17 - 1) + \
																SIZEOF_SUB_BAND_START_FREQ) // 2*(N-1)+2.1.2
#define CBTB_OUD_AGC_TABLE(ptr_cfg,N)						get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_AGC_TABLE, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (17 - 1) + \
																SIZEOF_SUB_BAND_START_FREQ + SIZEOF_RECEIVER_SYSTEM_GAIN) // 2*(N-1)+2.1.3
#define CBTB_OUD_CHANNEL_EQUALIZATION_TABLE(ptr_cfg,N)		get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_CHANNEL_EQUALIZATION_TABLE, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (17 - 1) + \
																SIZEOF_SUB_BAND_START_FREQ + SIZEOF_RECEIVER_SYSTEM_GAIN + SIZEOF_AGC_TABLE) // 2*(N-1)+2.1.4
#define CBTB_OUD_BASEBAND_AMPLIFIER_TABLE(ptr_cfg,N)		get_cbtb(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg, SIZEOF_BASEBAND_AMPLIFIER_TABLE, \
																SIZEOF_GENERAL_PURPOSE_CALIBRATION + (SIZEOF_TRANSMITTER_CALIBRATION_PARAMETERS + SIZEOF_RSSI)\
																* (N-1) + SIZEOF_OUTPUT_POWER_LEVEL_M * (17 - 1) + \
																SIZEOF_SUB_BAND_START_FREQ + SIZEOF_RECEIVER_SYSTEM_GAIN + SIZEOF_AGC_TABLE + \ 
																SIZEOF_BASEBAND_AMPLIFIER_TABLE) // 2*(N-1)+2.1.5

/*#define CBTB_OUD_K_COEFFICIENT_OF_RSSI(ptr_cfg,N)            get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,1)     // 2*(N-1)+2.1.1
#define CBTB_OUD_B_COEFFICIENT_OF_RSSI(ptr_cfg,N)            get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,2)     // 2*(N-1)+2.1.2
#define CBTB_OUD_HIGH_GAIN_SWITCHING_RSSI_LEVEL(ptr_cfg,N)   get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,3)     // 2*(N-1)+2.1.3
#define CBTB_OUD_LOW_GAIN_SWITCHING_RSSI_LEVEL(ptr_cfg,N)    get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,4)     // 2*(N-1)+2.1.4
#define CBTB_OUD_I_DC_OFFSET_FOR_HIGH_GAIN(ptr_cfg,N)        get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,5)     // 2*(N-1)+2.1.5
#define CBTB_OUD_Q_DC_OFFSET_FOR_HIGH_GAIN(ptr_cfg,N)        get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,6)     // 2*(N-1)+2.1.6
#define CBTB_OUD_I_DC_OFFSET_FOR_LOW_GAIN(ptr_cfg,N)         get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,7)     // 2*(N-1)+2.1.7
#define CBTB_OUD_Q_DC_OFFSET_FOR_LOW_GAIN(ptr_cfg,N)         get_cfg(get_cfg_file(CALIBRATION_TABLE_FILE),ptr_cfg,2*(N-1)+3,1,8)     // 2*(N-1)+2.1.8*/


#endif
